package com.pig4cloud.pigx.wallet.api.feign;

import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
import com.pig4cloud.pigx.common.core.constant.ServiceNameConstants;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.wallet.dto.WalletContractAccountChangeDTO;
import com.pig4cloud.pigx.wallet.entity.ContractAccount;
import com.pig4cloud.pigx.wallet.entity.FundingRateSettlementRecord;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;

import java.math.BigDecimal;
import java.util.List;

/**
 * 合约账户Controller feign
 * <p>ContractAccountController
 *
 * @date 2022/8/29 15:14
 */
@FeignClient(contextId = "robotContractAccountControllerFeign",
        value = ServiceNameConstants.WALLET_SERVICE,
        path = "/contractaccount")
public interface WalletContractAccountControllerFeign {
    /**
     * 查询合约账户信息
     */
    String CONTRACT_INFO = "/contract/info";
    /**
     * 查询合约账户信息并锁定
     */
    String CONTRACT_INFO_LOCK = "/contract/info/lock";
    /**
     * 合约账户混合操作(新)
     */
    String CHANGE = "/change";
    /**
     * 资金费率记录表 新增
     */
    String FUNDING_RATE_SAVE = "/contract/fundingratesettlementrecord";

    /**
     * 查询合约账户信息
     *
     * @param dto  入参
     * @param from 来源
     * @return {@link R<ContractAccount>}
     * @since 2022/8/29 15:22
     */
    @PostMapping(CONTRACT_INFO)
    R<ContractAccount> contractInfo(@RequestBody WalletContractAccountChangeDTO dto, @RequestHeader(SecurityConstants.FROM) String from);

    /**
     * 查询合约账户信息并锁定查询合约账户信息
     *
     * @param dto  入参
     * @param from 来源
     * @return {@link R<ContractAccount>}
     * @since 2022/8/29 15:22
     */
    @PostMapping(CONTRACT_INFO_LOCK)
    R<ContractAccount> contractInfoLock(@RequestBody WalletContractAccountChangeDTO dto, @RequestHeader(SecurityConstants.FROM) String from);

    /**
     * 合约账户修改额度
     *
     * @param dtoList 参数集合
     * @param from    来源
     * @return {@link R}
     * @since 2022/9/13 17:36
     */
    @PostMapping(CHANGE)
    R<BigDecimal> change(@RequestBody List<WalletContractAccountChangeDTO> dtoList, @RequestHeader(SecurityConstants.FROM) String from);

    /**
     * 新增资金费率记录
     *
     * @param list 记录
     * @param from 权限
     */
    @PostMapping(FUNDING_RATE_SAVE)
    void saveFundingRate(@RequestBody List<FundingRateSettlementRecord> list, @RequestHeader(SecurityConstants.FROM) String from);
}
